package Controlador.stegsecret;

//Decompiled by DJ v3.10.10.93 Copyright 2007 Atanas Neshkov  Date: 3/6/2009 11:37:28 AM
//Home Page: http://members.fortunecity.com/neshkov/dj.html  http://www.neshkov.com/dj.html - Check often for new version!
//Decompiler options: packimports(3) 
//Source File Name:   utils.java


import java.io.FileInputStream;
import java.security.MessageDigest;

public class utils
{

 public utils()
 {
 }

 public static String calculaHashFichero(String s, String s1)
 {
     try
     {
         MessageDigest messagedigest = MessageDigest.getInstance(s);
         FileInputStream fileinputstream = new FileInputStream(s1);
         byte abyte0[] = new byte[8192];
         int i;
         while((i = fileinputstream.read(abyte0)) != -1) 
             messagedigest.update(abyte0, 0, i);
         byte abyte1[] = messagedigest.digest();
         String s2 = new String("");
         for(int j = 0; j < abyte1.length; j++)
             if((abyte1[j] & 0xff) <= 15)
                 s2 = s2.concat((new StringBuilder()).append("0").append(Integer.toHexString(abyte1[j] & 0xff)).toString());
             else
                 s2 = s2.concat(Integer.toHexString(abyte1[j] & 0xff));

         fileinputstream.close();
         return s2;
     }
     catch(Exception exception)
     {
         return null;
     }
 }

 public static int bufferToInt(byte abyte0[], int i)
 {
     int j = abyte0[i++];
     j <<= 8;
     j |= abyte0[i++] & 0xff;
     j <<= 8;
     j |= abyte0[i++] & 0xff;
     j <<= 8;
     j |= abyte0[i] & 0xff;
     return j;
 }

 public static int bufferToIntInv(byte abyte0[], int i)
 {
     i += 3;
     int j = abyte0[i--];
     j <<= 8;
     j |= abyte0[i--] & 0xff;
     j <<= 8;
     j |= abyte0[i--] & 0xff;
     j <<= 8;
     j |= abyte0[i] & 0xff;
     return j;
 }

 public static short bufferToShort(byte abyte0[], int i)
 {
     short word0 = 0;
     word0 |= abyte0[i++];
     word0 <<= 8;
     word0 |= (short)abyte0[i] & 0xff;
     return word0;
 }
}